package com.bbzn.device.client.service.emq.order.impl.mq;

import com.alibaba.fastjson.JSONObject;
import com.bbzn.device.client.constant.VideoCallConstant;
import com.bbzn.device.client.dataobject.SystemParam;
import com.bbzn.device.client.exception.DefinitException;
import com.bbzn.device.client.service.SystemParamByCacheService;
import com.bbzn.device.client.utils.OptionalBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

/**
 * @Author wulongbo
 * @Date 2021/12/16 16:19
 * @Version 1.0
 */
@Component
public class MqVideoCallImpl extends BaseMqSendImpl {

    @Autowired
    private SystemParamByCacheService systemParamByCacheService;

    @Override
    public String checkMap(String language) throws Exception {
        if (!OptionalBean.ofNullable(map.get("roomId")).isPresent()) {
            SystemParam systemParam = systemParamByCacheService.getValues(VideoCallConstant.VIDEO_CALL_ENUM, VideoCallConstant.VIDEO_CALL_UN_ROOM_ID_PREFIX + language);
            throw new DefinitException(systemParam.getCode(), systemParam.getMassage());
        }
        if (!OptionalBean.ofNullable(map.get("isHide")).isPresent()) {
            SystemParam systemParam = systemParamByCacheService.getValues(VideoCallConstant.VIDEO_CALL_ENUM, VideoCallConstant.VIDEO_CALL_UN_IS_HIDE_PREFIX + language);
            throw new DefinitException(systemParam.getCode(), systemParam.getMassage());
        }
        return JSONObject.toJSONString(map);
    }
}
